INCLUDE_DIRECTORIES(BEFORE ${PROJECT_SOURCE_DIR}/lib ${PROJECT_BINARY_DIR})

CHECK_FUNCTION_EXISTS(getopt HAVE_GETOPT)
IF(NOT HAVE_GETOPT)
  SET(SRC_EXTRA_FILES getopt.c)
ENDIF(NOT HAVE_GETOPT)

ADD_EXECUTABLE(zipcmp zipcmp.c ${SRC_EXTRA_FILES})
TARGET_LINK_LIBRARIES(zipcmp zip ${FTS_LIB} ${ZLIB_LIBRARIES})
IF(LIBZIP_DO_INSTALL)
  INSTALL(TARGETS zipcmp EXPORT ${PROJECT_NAME}-targets RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
ENDIF()

ADD_EXECUTABLE(zipmerge zipmerge.c ${SRC_EXTRA_FILES})
TARGET_LINK_LIBRARIES(zipmerge zip)
IF(LIBZIP_DO_INSTALL)
  INSTALL(TARGETS zipmerge EXPORT ${PROJECT_NAME}-targets RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
ENDIF()

ADD_EXECUTABLE(ziptool ziptool.c ${SRC_EXTRA_FILES})
TARGET_LINK_LIBRARIES(ziptool zip)
IF(LIBZIP_DO_INSTALL)
  INSTALL(TARGETS ziptool EXPORT ${PROJECT_NAME}-targets RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
ENDIF()
